(function(){
        var myChart=echarts.init(document.getElementById('left2'));

var option = {
    title: {text: '项目收缴率对比',
            textStyle: {color:"#21e6c1",fontSize: 18,fontFamily:"楷体"},
            left:'12%',
            top:'5%'},
    tooltip: {trigger: 'axis',
              axisPointer: {type: 'shadow'}
             },
    grid: {left:'5%',
           right:'5%',
           top:'20%',
           bottom:'5%',
           containLabel:true
       },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: [],
        axisLabel:{fontSize: 8,color:"white"},
        splitLine:{show: false}
    },
    yAxis: {
        type: 'value',
        axisLabel:{fontSize: 8,color:"white"},
        splitLine:{show: false}
    },
    series: [
        {
            name: '收缴率',
            type: 'line',
            stack: '总量',
            data: [],
            itemStyle: {normal:
                    {label: {show: true,
                            formatter: function (params) {
                                return (params.value * 100).toFixed(2) + '%'; // 将值转换为百分比并保留两位小数
                            },
                            position: 'top',
                            textStyle: {color: "white",fontSize: 8}
                        },
                                 color:"#43dde6"}
                        }
        }

    ]
};

function get_json_bar() {
    $.ajax({
        url: 'http://localhost:5000/left2',
        type: 'GET',
        success: function (e) {
        option.xAxis.data = e.map(subArray => subArray[0]);
        option.series[0].data = e.map(subArray => subArray[1]);
        myChart.setOption(option);
        setTimeout(get_json_bar,10000)
                               }
            });
}
//执行函数
get_json_bar();


          myChart.setOption(option);
})();